<template>
	<Layout>
		<template #title>律{{lawFirmType=='2'?'所':'师'}}荣誉</template>
		<ScrollRefresher @refresh="loadData">
			<view class="lawyer-honor-page">
				<view v-for="item of list" :key="item.awardId" class="lawyer-honor"
					@click.stop="tapDetail(item.awardId)">
					<view class="lawyer-honor__image aspect-fill">
						<image mode="aspectFill" :src="item.awardImage"></image>
					</view>
					<view class="lawyer-honor__intro ellipsis">
						{{item.title}}
					</view>
				</view>
			</view>
		</ScrollRefresher>
	</Layout>
</template>

<script setup lang="ts" name="LawyerHonor">
	import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app';
	import { getLawfirmAwardList } from '@/apis/lawfirm';
	import { ref } from 'vue';
	import type { AnyObj } from '@/types/global';

	let lawFirmId = '';
	const lawFirmType = ref('1');
	const list = ref<AnyObj[]>([]);

	function tapDetail(id : string) {
		uni.navigateTo({
			url: `/pages-lawyer/honor-detail/honor-detail?id=${id}`
		})
	}

	function loadData() {
		getLawfirmAwardList(lawFirmId).then((res) => {
			list.value = res.rows ?? [];
		});
	}


	onPullDownRefresh(() => {
		loadData();
		setTimeout(() => {
			uni.stopPullDownRefresh();
		}, 500);
	});

	onLoad((options) => {
		options = options as { lawFirmId : string; lawFirmType : string; }
		lawFirmId = options.lawFirmId;
		lawFirmType.value = options.lawFirmType;
		loadData();
	});
</script>

<style lang="scss">
	.lawyer-honor-page {
		display: inline-flex;
		flex-wrap: wrap;
		width: 100%;
		padding: 0 32rpx;
		box-sizing: border-box;
	}
</style>